home *** CD-ROM | disk | FTP | other *** search
- Path: solon.com!not-for-mail
- From: seebs@solutions.solon.com (Peter Seebach)
- Newsgroups: comp.lang.c
- Subject: Re: Type casting
- Date: 2 Mar 1996 10:40:50 -0600
- Organization: Usenet Fact Police (Undercover)
- Message-ID: <4h9tmi$hmq@solutions.solon.com>
- References: <4gfnmi$gsc@calvin.risq.qc.ca> <4h5amm$dpv@umbc9.umbc.edu> <4h7oktINN433@anvil.ugrad.cs.ubc.ca>
- NNTP-Posting-Host: solutions.solon.com
-
- In article <4h7oktINN433@anvil.ugrad.cs.ubc.ca>,
- Kazimir Kylheku <c2a192@ugrad.cs.ubc.ca> wrote:
- >The reason is a few sentences early in the ISO standard which say that main()
- >shall be declared such and such, as I was surprised to find!
-
- No, they say it *may* be declared such and such.
-
- >Any further justifications may be informative, but are actually superfluous.
- >If the assertion were removed from the standard, it would be legal to declare
- >main() any way you like, and the conforming environment would have to make
- >sure to call it with a compatible sequence no matter how you define this.
-
- This is incorrect.
-
- No assertion exists in the standard that main may not be declared other ways.
-
- Actually, the key is 3.16, which states that it is undefined behavior
- whenever anything is done that is not explicitly defined.
-
- >However, main()
- >is not called from an expression within the C program, so this rule doesn't
- >apply to it.
-
- You certainly could call it, in which case, your calls would be required
- to match your definition.
-
- >You are required to write main() a certain way if you expect to write standard
- >C, and that is all there is to it. There is no necessary reason why it _has_
- >to be that way.
-
- No, but a strong logical one - modern OS's (even including DOS, for once)
- have a concept of whether a program has succeeded or failed.
-
- >Incidentally, the only specific reference to undefined behavior in the context
- >of main() that I have been able to dig up in the Standard says that the exit
- >status of a program which doesn't provide a return value on exit from main()
- >is undefined. There is no discussion over T main() where T is not int,
- >versus int main().
-
- This is because there's no need for it. There's also no discussion of what
- stdin->_cnt does.
-
- 3.16 renders all such behavior undefined, and therefore a bad idea.
-
- -s
- --
- Peter Seebach - seebs@solon.com - Copyright 1996 Peter Seebach.
- C/Unix wizard -- C/Unix questions? Send mail for help. No, really!
- FUCK the communications decency act. Goddamned government. [literally.]
- The *other* C FAQ - http://www.solon.com/~seebs/c/c-iaq.html
-